﻿using WebApiClientCore;
using WebApiClientCore.Attributes;
using BPM.Web.Shared.Data;
using BPM.Web.Shared.Auth;

namespace BPM.Web.Shared.Service;

[TokenFilter]
public interface ITimerClient : IHttpApi
{
    /// <summary>
    /// 分页获取任务列表
    /// </summary>
    /// <param name="body"></param>
    /// <param name="token"></param>
    /// <returns></returns>
    [HttpGet("sysTimers/page")]
    ITask<XnRestfulResult<PageResult<JobOutput>>> PageAsync(TimerPageInput body, CancellationToken token = default);

    /// <summary>
    /// 获取所有本地任务
    /// </summary>
    /// <param name="token"></param>
    /// <returns></returns>
    [HttpGet("sysTimers/localJobList")]
    ITask<XnRestfulResult<List<TaskMethodInfo>>> LocalJobListAsync(CancellationToken token = default);

    /// <summary>
    /// 增加任务
    /// </summary>
    /// <param name="body"></param>
    /// <param name="token"></param>
    /// <returns></returns>
    [HttpPost("sysTimers/add")]
    ITask<XnRestfulResult<string>> AddAsync(AddJobInput body, CancellationToken token = default);

    /// <summary>
    /// 删除任务
    /// </summary>
    /// <param name="body"></param>
    /// <param name="token"></param>
    /// <returns></returns>
    [HttpPost("sysTimers/delete")]
    ITask<XnRestfulResult<string>> DeleteAsync(DeleteJobInput body, CancellationToken token = default);

    /// <summary>
    /// 修改任务
    /// </summary>
    /// <param name="body"></param>
    /// <param name="token"></param>
    /// <returns></returns>
    [HttpPost("sysTimers/edit")]
    ITask<XnRestfulResult<string>> EditAsync(UpdateJobInput body, CancellationToken token = default);

    /// <summary>
    /// 查看任务
    /// </summary>
    /// <param name="body"></param>
    /// <param name="token"></param>
    /// <returns></returns>
    [HttpGet("sysTimers/detail")]
    ITask<XnRestfulResult<SysTimer>> DetailAsync(QueryTimerInput body, CancellationToken token = default);

    /// <summary>
    /// 停止任务
    /// </summary>
    /// <param name="body"></param>
    /// <param name="token"></param>
    /// <returns></returns>
    [HttpPost("sysTimers/stop")]
    ITask<XnRestfulResult<string>> StopAsync(StopJobInput body, CancellationToken token = default);

    /// <summary>
    /// 启动任务
    /// </summary>
    /// <param name="body"></param>
    /// <param name="token"></param>
    /// <returns></returns>
    [HttpPost("sysTimers/start")]
    ITask<XnRestfulResult<string>> StartAsync(AddJobInput body, CancellationToken token = default);
}
